<style scoped src="./index.scss" lang="scss" rel="stylesheet/scss"></style>
<template src="./index.html"></template>
<script>
export default {
  mixins: [Vue.prototype.$vFN.Mixins.Base, Vue.prototype.$vFN.Mixins.Edit],
  components: {
    SelectImage: async () =>
      Vue.extend(await Vue.prototype.$vFN.Components.Base.SelectImage()),
    SelectDateCycleApplication: async () =>
      Vue.extend(
        await Vue.prototype.$vFN.Components.Base.SelectDateCycleApplication()
      ),
  },
  data() {
    return {
      appWindow: window,
      form: {
        // 营业状态0关闭1开启
        operate_status: 1,
        // 营业时间
        operate_list: [],

        // 是否可以线上快递1可以
        send_online: 1,
        // 是否可以线下自提1可以
        send_offline: 1,  
        // 提货地址类型1与本店地址相同
        offline_type: 1,
        // 自提地址(其他地址)
        offline_address: "",
      },

      load: true,
    };
  },
  methods: {
    async init() {
      this.getData();
    },
    async getData() {
      let res = await this.$vFN.Http.post(
        {
          url: "store/setting/detail",
        },
        window
      );
      this.form.send_online = res.data.send_online;
      this.form.send_offline = res.data.send_offline;
      this.form.offline_type = res.data.offline_type;
      this.form.offline_address = res.data.offline_address;

      this.form.operate_status = res.data.operate_status;
      // 页面显示需要转换
      if (typeof res.data.operate_list == "string") {
        this.form.operate_list = JSON.parse(res.data.operate_list);
      }
      if (res._ok) {
        this.load = false;
      }
    },
    // 提交
    async sum() {
      this.load = true;
      let res = await this.$vFN.Http.post(
        {
          url: "store/setting/operate",
          data: {
            send_online: this.form.send_online,
            send_offline: this.form.send_offline,
            offline_type: this.form.offline_type,
            offline_address: this.form.offline_address,
            operate_status: this.form.operate_status,
            operate_list: JSON.stringify(this.form.operate_list),//提交时需要转换
          },
        },
        window
      );
      if (res._ok) {
        this.$vFN.Tools.messageSuccess("操作成功");
        this.getData();
      }
    },
  },
  mounted() {
    this.init();
  },
  activated() {},
};
</script>